﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MOCSoftware.Utilities.JpgMetaDataViewer.Properties;
using MOCSoftware.Utilities.JpgMetaDataViewer.Utility;

namespace MOCSoftware.Utilities.JpgMetaDataViewer.Model
{
    internal class JpgManager
    {
        internal event EventHandler<FileLoadDialogueFileSelectedEventArgs> FileLoadDialogueFileSelectedHandler;

        internal void LoadJpgImage()
        {
            var dlg = new Microsoft.Win32.OpenFileDialog();
            SetDialogOptions(dlg, Resources.MainWindow_FileLoadDialogTitle);
            if (dlg.ShowDialog() ?? false)
            {
                if (FileLoadDialogueFileSelectedHandler != null)
                    FileLoadDialogueFileSelectedHandler(this, new FileLoadDialogueFileSelectedEventArgs { FileName = dlg.FileName });
            }
        }

        private void SetDialogOptions(Microsoft.Win32.FileDialog dialog, string title)
        {
            dialog.AddExtension = true;
            dialog.CheckPathExists = true;
            dialog.DefaultExt = ".jpg";
            dialog.Filter = "JPeg Files (*.jpg)|*.jpg";
            dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            dialog.Title = title;
            dialog.ValidateNames = true;
        }

    }
}
